import {v4 as uuidv4} from 'uuid'

//要生成一个随机字符串作为游客id,持久存储
export const getUUID=()=>{
    //先从本地获取
    let uuid_token=localStorage.getItem('UUIDTOKEN')
    if(!uuid_token){
        //若本地没有再生成uuid
        uuid_token=uuidv4()
        //将生成的uuid存储在本地存储
        localStorage.setItem('UUIDTOKEN',uuid_token)
    }
    //切记有返回值
    return uuid_token
}